﻿namespace WMS6.Web.Analytics
{
    using System;
    using System.Data;
    using System.Text;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using WMS6.Web;
    using WMS6.Web.BaseInfoServiceRef;
    using WMS6.Web.UserControls;

    public class UDFReportList : BasePage
    {
        protected HtmlAnchor aaa;
        protected Button btnPrint;
        protected Button btnRefresh;
        protected HtmlForm F15131;
        protected HtmlInputHidden hdnFrom;
        protected HtmlInputHidden hdnReportID;
        protected HtmlInputHidden hdnStatus;
        protected Label lblMsg;
        protected Label lblUDFReportList;
        protected HtmlLink mycss;
        protected HtmlAnchor printA;
        protected ScriptManager ScriptManager1;
        protected HtmlGenericControl SideLeftMenu;
        protected HtmlGenericControl Udfiframe;
        protected UDFReportCtrl UDFReportCtrl1;
        protected UpdatePanel up1;

        private void BindData2gvUDFReport(UdfReportSettingQueryEntity udfReportQuery)
        {
            DataSet dsUDFReport = BaseInfoServiceClientProxy.GetInstance().GetAllInfo("UDF_REPORT_SETTING");
            StringBuilder StrHtml = new StringBuilder();
            StrHtml.Append("<dl >");
            for (int i = 0; dsUDFReport.Tables[0].Rows.Count > i; i++)
            {
                StrHtml.AppendFormat(" <dd> <a  href=\"#\"  id=aaa{2}  onclick=\"dd('{0}');\" >{1}</a></dd>", dsUDFReport.Tables[0].Rows[i]["REPORT_ID"], dsUDFReport.Tables[0].Rows[i]["REPORT_NAME"], i);
            }
            StrHtml.Append("</dl>");
            this.SideLeftMenu.InnerHtml = StrHtml.ToString();
        }

        protected void btnPrint_Click(object sender, EventArgs e)
        {
            this.UDFReportCtrl1.GetUdfReoprtCtrlValue();
            this.Udfiframe.Attributes.Add("src", string.Format("../Common/PrintReport.aspx?rtype=UDFREPORT&udfreportid={0}", this.hdnReportID.Value));
        }

        protected void btnRefresh_Click(object sender, EventArgs e)
        {
            UdfReportSettingQueryEntity udfReportQuery = this.GetUdfReportSettingQueryEntity();
            this.BindData2gvUDFReport(udfReportQuery);
        }

        private UdfReportSettingQueryEntity GetUdfReportSettingQueryEntity()
        {
            return (base.PageQueryEntitySession as UdfReportSettingQueryEntity);
        }

        private void LoadData()
        {
            UdfReportSettingQueryEntity udfReportQuery = new UdfReportSettingQueryEntity {
                IsGetAll = false,
                CurrentPage = "0",
                SortField = "",
                SortDirection = ""
            };
            this.SetUdfReportSettingQueryEntity(udfReportQuery);
            this.BindData2gvUDFReport(udfReportQuery);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                base.InitPage(this.Page);
                this.LoadData();
            }
        }

        protected void ReportLoad(object sender, EventArgs e)
        {
            this.UDFReportCtrl1.UdfReportCtrlLoad(this.hdnReportID.Value, "UDF_REPORT_SETTING");
        }

        public void SetUdfReportSettingQueryEntity(UdfReportSettingQueryEntity udfReportQuery)
        {
            base.PageQueryEntitySession = udfReportQuery;
        }
    }
}

